//search模块的小仓库
import { reqGetSearchInfo } from "@/api"
const actions = {
    //获取search的数据
    async getSearchList({ commit }, params = {}) {
        //这个reqGetSearchInfo这个函数在调用获取服务器数据的时候，至少要传一个空对象
        //params形参：是当用户发action的时候，第二个参数传过来，至少是一个空对象
        let result = await reqGetSearchInfo(params);
        if (result.code == 200) {
            commit('GETSEARCHLIST', result.data);
        }
    }
}//响应组件中动作
const mutations = {
    GETSEARCHLIST(state, searchList) {
        state.searchList = searchList;
    }

}//操作数据（state中）
const state = {
    searchList: {}
}//存储数据
const getters = {
    goodsList(state) {
        return state.searchList.goodsList || [];
    },
    trademarkList(state) {
        return state.searchList.trademarkList || [];
    },
    attrsList(state) {
        return state.searchList.attrsList || [];
    }
}//类似于计算属性

export default {
    state, mutations, actions, getters

}